<template>
  <div class="item-wrap">
    <div class="info-img" v-if="isImgShow">
      <a :href="`${newsBasePath}${data.link}`" target="_blank">
        <img :src="`${imagePath}/${data.imageName}`" width="165" height="100" />
      </a>
    </div>
    <div class="info-content">
      <div class="info-title">
        <a :href="`${newsBasePath}${data.link}`" target="_blank">{{ data.subject }}</a>
        <template v-if="data.extText">
          <section v-for="(ext, i) in data.extText" :key="i" class="ib">
            <Tag :value="ext[0]" />
          </section>
        </template>
        <Icon :item="data" />
      </div>
      <div class="brief" v-if="data.brief">{{ data.brief }}</div>
      <div class="info-time">
        <span>{{ data.publishDepartment }}</span> <span>{{ data.publishMember }}</span>
        <span>{{ data.createDate }}</span>
        <span>{{ i18n('common.bbs.block.label') }}：{{ data.typeName }}</span>
      </div>
    </div>
  </div>
</template>

<script>
  import Tag from '@/components/news/components/tag';
  import Icon from '@/components/common/newsTitleIcons.vue';
  export default {
    name: 'NewsItem',
    components: {
      Icon,
      Tag
    },
    props: {
      data: {
        type: Object
      }
    },
    data() {
      return {
        imagePath: uploadPath,
        newsBasePath: `${_basePath}/`
      };
    },
    computed: {
      isImgShow() {
        return (
          this.data.morePageShowImage &&
          this.data.imageName != '' &&
          this.data.imageName != undefined
        );
      }
    },
    methods: {
      i18n(code) {
        return $.i18n(code);
      }
    }
  };
</script>

<style lang="scss" scoped>
  .item-wrap {
    padding: 14px 0 13px;
    // height: 130px;
    margin: 0 30px;
    overflow: hidden;
    border-bottom: 1px solid #f3f3f3;

    .info-img {
      float: left;
      width: 165px;
      height: 100px;
      // margin-top: 15px;
      margin-right: 10px;
      overflow: hidden;
      cursor: pointer;

      //fixme: delete
      border: 1px solid lightblue;
    }

    .info-content {
      position: relative;
      // margin-left: 180px;
      // height: 100%;
      // padding: 14px 0 13px 0;
      overflow: hidden;
      text-align: left;

      .info-title {
        width: auto;
        height: 30px;
        margin-right: 5px;
        margin-bottom: 5px;
        overflow: hidden;
        font-size: 16px;
        font-weight: bold;
        line-height: 30px;
        color: #333;
        -o-text-overflow: ellipsis;
        text-overflow: ellipsis;
        white-space: nowrap;

        > div {
          display: inline-block;
        }
      }

      .info-title:hover {
        color: #ff3126;
        cursor: pointer;
      }

      .brief {
        display: -webkit-box;
        height: 45px;
        overflow: hidden;
        font-size: 12px;
        line-height: 21px;
        color: #666;
        text-overflow: ellipsis;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
      }

      .info-time {
        // position: absolute;
        bottom: 40px;
        font-size: 12px;
        color: #999;

        > span {
          margin-right: 10px;

          > span {
            margin-right: 0;
          }
        }
      }
    }
  }

  .ib {
    display: inline-block;
  }
</style>
